<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    ! function () {
        var d = new Date()
        console.log(d.constructor == Date)
        var arr = [1, 2, 3]
        console.log(arr.constructor)
        var obj = {}
        console.log(obj.constructor)
        console.log(typeof d === typeof arr)

        function Derived() {
            console.log("Derived")
        }

        function Base() {
            console.log("Base")
        }
        Derived.prototype = new Base()
        var obj = new Derived()
        console.log(obj.constructor)
        Derived.prototype.constructor = Derived
        console.log(obj.constructor)
    }()


    ! function () {
        var d = new Date();
        console.log(d instanceof Date)
        console.log(d instanceof Object)

        function Derived() {};

        function Base() {};
        Derived.prototype = new Base()
        var obj = new Derived()
        // console.log(obj instanceof Derived)
        // console.log(obj instanceof Base)
        // console.log(obj instanceof Object)
        console.log(Derived.prototype.isPrototypeOf(obj))
        console.log(Base.prototype.isPrototypeOf(obj))
        console.log(Object.prototype.isPrototypeOf(obj))
    }()


    // 数据类型判定(鸭子类型)
    ! function () {
        var obj = {}
        obj.doit = function () {
            console.log("doit")
        }

        var obj2 = {
            doit: function () {
                console.log("doit")
            }
        }
        console.log("doit" in obj)
        // console.log("doit" instanceof obj)
        console.log(obj)
        console.log(obj2)
        console.log(obj2 == obj)
        obj2.doit()
        obj.doit()
        console.log("constructor" in obj)
        console.log(obj)
    }()

    //属性的枚举
    ! function () {
        var obj = {
            x: 1,
            u: 2
        }
        console.log(obj)
        console.log(Object.keys(obj))
        console.log(Object.getOwnPropertyNames(obj))
        var arr = [1, 2]
        console.log(arr)
        console.log(Object.keys(arr))
        console.log(Object.getOwnPropertyNames(arr))
        console.log(Object.keys(obj.__proto__))
        console.log(obj.__proto__ === Object.prototype)
        console.log(Object.getOwnPropertyNames(Object.prototype))
        console.log(Object.getOwnPropertyNames(obj.__proto__))
    }()
</script>